package com.ruoyi.web.controller.projectAch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.projectAch.domain.SchoolName;
import com.ruoyi.projectAch.service.ISchoolNameService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 维护学校名称Controller
 *
 * @author ruoyi
 * @date 2023-12-31
 */
@RestController
@RequestMapping("/projectAch/schoolName")
public class SchoolNameController extends BaseController
{
    @Autowired
    private ISchoolNameService schoolNameService;

    /**
     * 查询维护学校名称列表
     */
    @PreAuthorize("@ss.hasPermi('projectAch:schoolName:list')")
    @GetMapping("/list")
    public TableDataInfo list(SchoolName schoolName)
    {
        startPage();
        List<SchoolName> list = schoolNameService.selectSchoolNameList(schoolName);
        return getDataTable(list);
    }

    /**
     * 导出维护学校名称列表
     */
    @PreAuthorize("@ss.hasPermi('projectAch:schoolName:export')")
    @Log(title = "维护学校名称", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SchoolName schoolName)
    {
        List<SchoolName> list = schoolNameService.selectSchoolNameList(schoolName);
        ExcelUtil<SchoolName> util = new ExcelUtil<SchoolName>(SchoolName.class);
        util.exportExcel(response, list, "维护学校名称数据");
    }

    /**
     * 获取维护学校名称详细信息
     */
    @PreAuthorize("@ss.hasPermi('projectAch:schoolName:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(schoolNameService.selectSchoolNameById(id));
    }

    /**
     * 新增维护学校名称
     */
    @PreAuthorize("@ss.hasPermi('projectAch:schoolName:add')")
    @Log(title = "维护学校名称", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SchoolName schoolName)
    {
        return toAjax(schoolNameService.insertSchoolName(schoolName));
    }

    /**
     * 修改维护学校名称
     */
    @PreAuthorize("@ss.hasPermi('projectAch:schoolName:edit')")
    @Log(title = "维护学校名称", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SchoolName schoolName)
    {
        return toAjax(schoolNameService.updateSchoolName(schoolName));
    }

    /**
     * 删除维护学校名称
     */
    @PreAuthorize("@ss.hasPermi('projectAch:schoolName:remove')")
    @Log(title = "维护学校名称", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(schoolNameService.deleteSchoolNameByIds(ids));
    }
}
